package com.example.treasure_back.config;

import com.example.treasure_back.shiroEntity.auth.AuthUserMethodArgumentResolver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

@Configuration
public class ConfigAdapter implements WebMvcConfigurer {

    @Autowired
    AuthUserMethodArgumentResolver authUserMethodArgumentResolver;
    @Value("${daily.file.path}")
    private String dailyFilePath;
    @Value("${daily.file.location}")
    private String dailyFileLocation;
    @Value("${avatar.file.path}")
    private String avatarFilePath;
    @Value("${avatar.file.location}")
    private String avatarFileLocation;


    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
        WebMvcConfigurer.super.addArgumentResolvers(resolvers);
        resolvers.add(authUserMethodArgumentResolver);
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(dailyFilePath).addResourceLocations(dailyFileLocation);
        registry.addResourceHandler(avatarFilePath).addResourceLocations(avatarFileLocation);
        WebMvcConfigurer.super.addResourceHandlers(registry);
    }
}
